import request from '@/utils/request'


export default {
  //列表
  getPageList(page,limit,searchObj){
    return request({
      url: '/admin/system/role'+"/"+page+"/"+limit,
      method: 'get',
      params: searchObj
    })
  },

  //删除
  removeById(id){
    return request({
      url: '/admin/system/role/remove/'+id,
      method: 'delete',
    })
  },

  //添加
  saveRole(role){
    return request({
      //接口路径
      url:'/admin/system/role/save/',
      method: 'post',
      //传递json格式数据
      data: role
    })
  },

  //根据id查询
  getRoleById(id){
    return request({
      url: '/admin/system/role/findRoleById/'+id,
      method: 'get',
    })
  },
  //修改的方法
  update(role){
    return request({
      url: '/admin/system/role/update',
      method: 'post',
      data: role
    })
  },

  //批量删除
  batchRemoveById(idList){
    return request({
      url: '/admin/system/role/batchRemove/',
      method: 'delete',
      data: idList
    })
  },

  //根据用户id查询用户已分配的角色
  getRolesByUserId(userId) {
    return request({
      url: '/admin/system/role/toAssign/'+userId,
      method: 'get'
    })
  },

  //分配角色
  assignRoles(assginRoleVo) {
    return request({
      url: '/admin/system/role/doAssign/',
      method: 'post',
      data: assginRoleVo
    })
  }
}
